package com.mstore.action;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.mstore.config.Constants;
import com.mstore.interceptor.Authority;
import com.mstore.pojo.Account;
import com.mstore.pojo.Balance;
import com.mstore.pojo.BaseAct;
import com.mstore.pojo.BaseMember;
import com.mstore.pojo.BgiveRule;
import com.mstore.pojo.Consume;
import com.mstore.pojo.EnterpriseIntegralRule;
import com.mstore.pojo.ExchangeGood;
import com.mstore.pojo.ExchangeLog;
import com.mstore.pojo.Member;
import com.mstore.pojo.SMSLog;
import com.mstore.pojo.Score;
import com.mstore.pojo.Shop;
import com.mstore.pojo.User;
import com.mstore.service.AccountService;
import com.mstore.service.BApplicationService;
import com.mstore.service.BalanceService;
import com.mstore.service.BaseActService;
import com.mstore.service.BaseMemberService;
import com.mstore.service.BgiveRuleService;
import com.mstore.service.ConsumeService;
import com.mstore.service.EnterpriseIntegralRuleService;
import com.mstore.service.ExchangeGoodsService;
import com.mstore.service.ExchangeLogsService;
import com.mstore.service.MemberService;
import com.mstore.service.SMSLogService;
import com.mstore.service.ScoreService;
import com.mstore.service.ShopService;
import com.mstore.service.UserService;
import com.mstore.util.CookieUtils;
import com.mstore.util.MD5Util;
import com.mstore.util.SendPswSms;
import com.mstore.util.SendSms;

/**
 * 会员信息操作
 */
public class MemberAction extends BaseAction implements SessionAware,
		ServletRequestAware, ServletResponseAware {

	private static final long serialVersionUID = 3544075788594208553L;

	private MemberService memberService;

	private ShopService shopService;

	private BaseActService baseactService;

	private ScoreService scoreService;

	private ConsumeService consumeService;

	private BalanceService balanceService;

	private ExchangeGoodsService exchangeGoodsService;

	private ExchangeLogsService exchangeLogsService;

	private EnterpriseIntegralRuleService enterpriseIntegralRuleService;

	private BApplicationService bApplicationService;

	private BgiveRule bGiveRule;

	private UserService userService;

	private Member member;

	private BaseAct baseact;

	private Shop shop;

	private String json;

	private String mobile;

	private String addplace;

	/********** struts2无法准确无误的把BaseAct对象的积分和余额转换为对应的Double所以要单独获取在转换set **********/
	private String balance;

	private String score;

	private String exScore;

	/************ 企业管理员分页查询的两个参数 **********/
	private int index;

	private int page;

	private int line;

	/************ 商品兑换 **********/
	private String exGoodid;

	private ExchangeGood exGood;

	private List<ExchangeGood> exGoods;

	private ExchangeLog exchangeLog;

	private List<ExchangeLog> exchangeLogs;

	/********** 用来判断是否使用会员余额交易 ***********/
	private int type;

	/********** 判断交易查询还是充值查询 ***********/
	private String seekType;

	private String money;

	private List<Member> members;

	private List<Consume> consumes;

	private List<Balance> balances;

	private String back;

	private String result;

	/********** 判断当前会员的积分活动 ***********/
	private AccountService accountService;

	private BgiveRuleService bGiveRuleService;

	private List<BgiveRule> bGiveRules = new ArrayList<BgiveRule>();;

	private String message;

	private String searchOneMember;

	public final long spaceTime = 30;

	public final long spaceTimeForSms = 60;

	private String memberMobile;

	private Boolean timeOut;

	private Map<String, Object> session;

	private HttpServletRequest request;

	private HttpServletResponse response;

	private String messageMoney;

	/**
	 * 用户登录名
	 */
	private String loginName;

	/**
	 * 用户登录密码
	 */
	private String password;

	/**
	 * 会员总数
	 */
	private Integer memberCount;

	/**
	 * 企业登陆的权限标示 如果企业完善了信息，则可以正常使用功能 否则，不显示功能，只能先完善企业信息
	 */
	private String qyAuthority;

	/**
	 * 昵称
	 */
	private String nickName;

	private static Logger logger = Logger.getLogger(MemberAction.class
			.getName());

	private SMSLogService smsLogService;

	/**
	 * 会员在某企业的积分
	 */
	private double memberLogScore;

	/**
	 * 会员在某企业的充值余额
	 */
	private double memberLogBalance;

	private BaseMemberService baseMemberService;

	private BaseMember baseMember;

	private Consume consume;

	private List<BaseMember> baseMembers;

	/**
	 * 此次购物所获积分
	 */
	private Double scoreOfConsume = 0.0;

	/**
	 * 验证码
	 */
	private String verifyCodeForConsume;

	/**
	 * 存放验证码的池
	 */
	private static Map<String, Object[]> REG_CODE_MAP = new ConcurrentHashMap<String, Object[]>();

	static {
		Timer timer = new Timer(true);
		timer.schedule(new TimerTask() {

			public void run() {
				try {
					long time = System.currentTimeMillis() / 1000;
					for (Entry<String, Object[]> entry : REG_CODE_MAP
							.entrySet()) {
						Object[] obj = entry.getValue();
						// 5分钟内有效
						if (time - ((Long) obj[0]).longValue() > 5 * 60) {
							REG_CODE_MAP.remove(entry.getKey());
						}
					}
				}
				catch (Exception e) {
				}
			}
		}, 5 * 60 * 1000, 60 * 1000);
	}

	/**
	 * 进入登陆页面
	 */
	@Authority(actionName = "maccount", privilege = "pass")
	public String initLogin() {
		CookieUtils cookieUtils = new CookieUtils();
		if (request != null) {
			loginName = cookieUtils.getLoginNameFromCookie(request);
		}
		return "toLoginJsp";
	}

	/**
	 * 登陆
	 */
	@Authority(actionName = "maccount", privilege = "pass")
	public String login() {
		if (StringUtils.isBlank(loginName)) {
			result = "请输入手机号或邮箱或昵称";
			return "logerror";
		}

		if (StringUtils.isBlank(password)) {
			result = "请输入密码";
			return "logerror";
		}

		// 登录验证
		// 由于手机号、邮箱、昵称（兼顾老会员）格式各不相同
		// 不会出现互扰现象
		// 昵称逐步退出用作登陆名
		member = memberService.checkMember(loginName, password);

		if (member == null) {
			result = "登录名或密码错误";
			return "logerror";
		}

		// 根据会员的type属性选择登陆的首页
		// 1、会员；2、企业；3、店员
		CookieUtils cookieUtils = new CookieUtils();
		switch (member.getType()) {
			case 1:
				// 会员登陆
				try {
					// 删除 可能已存在的cookie
					cookieUtils.delCookie(request, CookieUtils.LOGIN_NAME);
					// 将loginName保存到cookie中
					// 此处不考虑loginName是否有效
					response.addCookie(cookieUtils
							.addLoginNameInCookie(loginName));

					String url = Constants.memberUrl
							+ "?shopToM=1&member.loginName=" + loginName
							+ "&member.password=" + member.getPassword();
					response.sendRedirect(url);
				}
				catch (IOException e) {
					logger.error(e.getMessage());
					e.printStackTrace();
				}
				return NONE;
			case 2:
				// 企业登陆
				Account account = new Account();
				account.setMember(member);
				account = accountService.findAccountByMemberId(account);
				// 将account保存到session
				session.put("account", account);
				// 删除 可能已存在的cookie
				cookieUtils.delCookie(request, CookieUtils.LOGIN_NAME);
				// 将loginName保存到cookie中
				response.addCookie(cookieUtils.addLoginNameInCookie(loginName));

				// 检查企业信息是否完善
				// 如果没有完善就不能使用系统功能
				if (StringUtils.isBlank(account.getEmail())
						|| StringUtils.isBlank(account.getName())
						|| StringUtils.isBlank(account.getLoginName())) {
					qyAuthority = "no";
					return "accountNo";
				}
				else {
					qyAuthority = "yes";
				}

				return "accountlogin";
			case 3:
				// 店员登陆
				User user = new User();
				user.setMember(member);
				user = userService.findUserByMemberId(user);
				// 将user保存到session
				session.put("user", user);
				// 删除 可能已存在的cookie
				cookieUtils.delCookie(request, CookieUtils.LOGIN_NAME);
				// 将user保存到cookie中
				response.addCookie(cookieUtils.addLoginNameInCookie(loginName));
				return "userlogin";
			default:
				result = "用户名或密码错误";
				return "logerror";
		}

	}

	/**
	 * 安全退出
	 */
	public String logout() {
		session.clear();
		return "logout";
	}

	/**
	 * 分页查询企业下的会员
	 * 
	 * @return
	 */
	public String getAllMember() {
		String temp = "error";
		Object obj = session.get("account");
		if (obj == null) {
			result = "系统异常，请重新登陆";
			return temp;
		}
		Account account = (Account) obj;
		Long eaId = account.getId();
		this.line = baseMemberService.countBaseMemberByEaId(eaId);
		this.memberCount = this.line;

		if (this.line == 0) {
			this.line = 1;
		}
		if (this.line % 14 == 0) {
			this.page = this.line / 14;
		}
		else {
			this.page = (this.line / 14) + 1;
		}

		if (this.index < 1) {
			this.index = 1;
		}
		else if (this.index > this.page) {
			this.index = this.page;
		}

		this.baseMembers = baseMemberService.getBaseMembersByEaId(eaId,
				this.index);

		for (BaseMember bm : this.baseMembers) {
			Member m = memberService
					.getMemberById(new Member(bm.getMemberId()));
			bm.setMember(m);
		}

		temp = "getAllMember";
		return temp;
	}

	/**
	 * 查看会员基本信息
	 * 
	 * @return
	 */
	public String watchMember() {
		Object object = session.get("account");
		if (object == null) {
			result = "系统异常，请重新登陆！";
			return "error";
		}

		if (this.member == null || StringUtils.isBlank(this.member.getMobile())) {
			result = "系统异常，请重新登陆！";
			return "error";
		}

		Account account = (Account) object;
		Long eaId = account.getId();
		
		this.member = memberService.getMemberByMobileAndType(member);

		if (this.member == null) {
			result = "系统异常，请重新登陆！";
			return "error";
		}

		this.baseMember = baseMemberService.getOneBaseMemberByMemberIdAndEaId(
				this.member.getId(), eaId);

		// 获取消费记录
		Consume consume = new Consume();
		consume.setMemberId(member.getId());
		consume.setEaId(eaId);
		this.consumes = consumeService.getConsumeByIDAndEa(consume);
		for (Consume csume : consumes) {
			Shop shop = new Shop();
			shop.setId(csume.getShopId());
			shop = (Shop) shopService.getOneShop(shop);
			csume.setShop(shop);
		}

		// 获取充值记录
		Balance b = new Balance();
		b.setMemberId(this.member.getId());
		b.setEaId(eaId);
		this.balances = balanceService.getBalanceByEaIdAndMemberId(b);
		// 循环遍历 得到充值商铺的名称
		for (Balance bal : balances) {
			Shop shop = new Shop();
			shop.setId(bal.getShopId());
			shop = (Shop) shopService.getOneShop(shop);
			bal.setShop(shop);
		}

		return "toOneMember";
	}

	/**
	 * 通过手机号搜索企业的一名会员
	 * 
	 * @return
	 */
	public String getOneMember() {
		Account account = (Account) session.get("account");
		if (account == null) {
			result = "系统异常，请重新登陆";
			return "error";
		}
		Long eaId = account.getId();

		this.searchOneMember = "searchOneMember";

		this.memberCount = baseMemberService.countBaseMemberByEaId(eaId);

		baseMembers = new ArrayList<BaseMember>();
		if (this.member != null
				|| StringUtils.isNotBlank(this.member.getMobile())) {
			// 查询c_member表
			this.member = memberService.getMemberByMobileAndType(this.member);
			if (this.member == null) {
				return "getAllMember";
			}

			// 查询c_base_member表
			this.baseMember = baseMemberService
					.getOneBaseMemberByMemberIdAndEaId(this.member.getId(),
							eaId);
			if (this.baseMember == null) {
				return "getAllMember";
			}

			this.baseMember.setMember(this.member);
			baseMembers.add(this.baseMember);
			return "getAllMember";
		}

		return "getAllMember";
	}

	/**
	 * 购物结算获取会员信息及积分余额信息
	 * 
	 * @return
	 */
	public String seekMember() {
		try {
			String temp = "musererror";
			Object obj = session.get("user");
			if (obj == null) {
				result = "系统异常，请重新登陆";
				return "error";
			}

			if (this.member == null
					|| StringUtils.isBlank(this.member.getMobile())) {
				result = "手机号不能为空";
				return "error";
			}

			User user = (User) obj;
			Shop shop = new Shop();
			shop.setId(user.getShopId());
			shop = (Shop) shopService.getOneShop(shop);
			this.shop = new Shop();
			this.shop.setId(shop.getId());
			this.member = memberService.getMemberByMobileAndType(this.member);
			if (this.member != null) {
				this.member.setEaId(shop.getEaId());
				// 查询c_base_member表
				this.baseMember = baseMemberService
						.getOneBaseMemberByMemberIdAndEaId(this.member.getId(),
								shop.getEaId());

				if (this.baseMember == null) {
					this.baseMember = new BaseMember();
					this.baseMember.setBalance(0d);
					this.baseMember.setCreateTime("");
					this.baseMember.setLevel("");
					this.baseMember.setScore(0d);
				}

				// 判断交易查询,充值查询,还是兑换查询
				if (seekType.equals("shopseek")) {
					Consume consume = new Consume();
					consume.setMemberId(this.member.getId());
					consume.setEaId(shop.getEaId());
					consumes = new ArrayList<Consume>();
					consumes = consumeService.getConsumeByIDAndEa(consume);
					temp = "seekMemberShopping";
				}
				else if (seekType.equals("balance")) {

					Balance balance = new Balance();
					balance.setMemberId(this.member.getId());
					balance.setEaId(shop.getEaId());
					balances = new ArrayList<Balance>();
					balances = balanceService
							.getBalanceByEaIdAndMemberId(balance);
					temp = "seekMemberBalance";
				}
				else {
					this.exGood = new ExchangeGood();
					this.exGood.setEaId(this.member.getEaId());
					this.exGood.setShopId(shop.getId());
					this.exGoods = exchangeGoodsService
							.getAllExgoodList(this.exGood);
					ExchangeLog exchangelog = new ExchangeLog();
					exchangelog.setMemberId(this.member.getId());
					exchangelog.setEaId(shop.getEaId());
					List<ExchangeLog> eList = new ArrayList<ExchangeLog>();
					exchangeLogs = new ArrayList<ExchangeLog>();
					eList = exchangeLogsService
							.getExLogsByEaAndMemberId(exchangelog);
					for (int i = 0; i < eList.size(); i++) {
						ExchangeLog eLog = new ExchangeLog();
						eLog = eList.get(i);
						ExchangeGood exgood = new ExchangeGood();
						exgood = (ExchangeGood) exchangeGoodsService
								.getOneExgoodbyId(eList.get(i).getGoodId());
						Shop shop1 = new Shop();
						shop1.setId(eList.get(i).getShopId());
						shop1 = shopService.getShopById(shop1);
						eLog.setExchangeGood(exgood);
						eLog.setShop(shop1);
						exchangeLogs.add(eLog);
					}

					temp = "seekMemberExchange";
				}
			}
			else if (seekType.equals("shopseek")) {
				temp = "seekMemberShoppingError";
			}
			else if (seekType.equals("balance")) {
				temp = "seekMemberBalanceError";
			}
			else {
				temp = "seekMemberExchangeError";
			}
			return temp;
		}
		catch (Exception e) {
			logger.error("消费查询会员报错", e);
		}
		return NONE;
	}

	// 算会员兑换掉的全部积分
	public Double sumAllExchange(Member member) {
		Double score = 0d;
		ExchangeLog exchangeLog = new ExchangeLog();
		ExchangeGood exchangeGood = new ExchangeGood();
		exchangeLog.setMemberId(member.getId());
		List<ExchangeLog> exchangeLogs = exchangeLogsService
				.getExLogsByMember(exchangeLog);
		for (ExchangeLog exl : exchangeLogs) {
			exchangeGood.setId(exl.getGoodId());
			exchangeGood = exchangeGoodsService.getExgoodById(exchangeGood);
			score += exchangeGood.getScore();
		}
		return score;
	}

	/**
	 * 购物结算业务
	 * 
	 * @return
	 * @throws ParseException
	 */
	public String shopping() throws ParseException {
		try {
			Object object = session.get("user");
			if (object == null) {
				result = "系统异常，请重新登陆！";
				return "error";
			}
			if (this.member == null) {
				result = "系统异常，请重新登陆！";
				return "error";
			}
			if (this.baseMember == null) {
				result = "系统异常，请重新登陆！";
				return "error";
			}

			if (StringUtils.isBlank(this.money)) {
				result = "未填写消费金额";
				return "error";
			}

			User user = (User) object;
			this.shop = new Shop();
			this.shop.setId(user.getShopId());
			this.shop = shopService.getShopById(this.shop);
			if (this.shop == null) {
				result = "系统异常，请重新登陆！";
				return "error";
			}
			Account account = new Account();
			account.setId(this.shop.getEaId());
			account = accountService.findAccountById(account);
			if (account == null) {
				result = "系统异常，请重新登陆！";
				return "error";
			}
			// 计算本次购物所获得的积分，保存到this.baseMember变量中
			countBaseMemberSorce(account.getId());

			String createTime = getCreateTime();
			// 添加消费记录
			addConsume(type, createTime);
			// 传参数为1表示添加积分记录，为0表示兑换物品减去积分记录(此方法只做购物添加积分业务赋值1)
			// 添加积分记录
			addScore(1, createTime);
			// 设置积分等级
			getMemberLevelname(this.member, this.baseMember);
			this.baseMember.setLevel(this.member.getLevelName());

			// type为1表示采用的是余额支付
			if (type == 1)
				this.baseMember.setBalance(this.baseMember.getBalance()
						- Double.parseDouble(money));

			// 查询c_base_member
			BaseMember bm = baseMemberService
					.getOneBaseMemberByMemberIdAndEaId(this.member.getId(),
							account.getId());
			if (bm == null) {
				// 添加新数据
				this.baseMember.setEaId(account.getId());
				this.baseMember.setBalance(0d);
				this.baseMember.setCreateTime(createTime);
				this.baseMember.setMemberId(this.member.getId());
				baseMemberService.save(this.baseMember);
			}
			else {
				// 更新原有数据
				baseMemberService.updateBaseMember(this.baseMember);
			}

			return "shopping";
		}
		catch (Exception e) {
			logger.error("购物结算报错", e);
		}
		return NONE;
	}

	/**
	 * 购物结算30秒内不能消费值同一个账号
	 * 
	 * @return
	 * @throws ParseException
	 */
	public String timeOutShop() throws ParseException {

		long seconds = 61;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// 获得userid
		User user = (User) session.get("user");
		this.shop = new Shop();
		this.shop.setId(user.getShopId());
		this.shop = (Shop) shopService.getOneShop(shop);
		this.member = new Member();
		this.member.setMobile(memberMobile);

		this.member.setEaId(this.shop.getEaId());
		// 获得memberId
		this.member = (Member) memberService.getmemberByMobile(this.member);

		Consume consume = new Consume();
		// consume.setUser_id(user.getId());
		consume.setShopId(this.shop.getId());
		consume.setMemberId(this.member.getId());
		List<Consume> clist = consumeService.getConsumesByshop(consume);
		if (clist.size() == 0) {
			timeOut = false;
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("timeOut", timeOut);
			result = super.mapTojson(map);
			return "timeOutShop";
		}
		String consumeStr = clist.get(0).getCreateTime();
		Date exDate = df.parse(consumeStr);
		Date currentDate = new Date();
		long diff = currentDate.getTime() - exDate.getTime();
		seconds = diff / 1000;
		if (seconds <= spaceTime) {
			timeOut = true;
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("timeOut", timeOut);
			result = super.mapTojson(map);
			return "timeOutShop";
		}
		timeOut = false;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("timeOut", timeOut);
		result = super.mapTojson(map);
		return "timeOutShop";

	}

	/**
	 * 积分变化记录
	 * 
	 * @param shopmark
	 * @param dateTime
	 */
	public void addScore(int shopmark, String dateTime) {
		User user = (User) session.get("user");
		Score score = new Score();
		score.setMemberName(findMemberName(member).getName() == null ? ""
				: findMemberName(member).getName());
		score.setShopName(findShopName(shop).getName() == null ? ""
				: findShopName(shop).getName());
		score.setUserName(user.getUserName());
		Account ac = new Account();
		ac.setId(this.member.getEaId());
		ac = accountService.findAccountById(ac);
		score.setEaName(ac.getName());
		score.setUserId(user.getId());
		score.setEaId(this.member.getEaId());
		score.setMemberId(this.member.getId());
		score.setShopId(this.shop.getId());
		score.setCreateTime(dateTime);
		score.setNumer(this.scoreOfConsume);
		score.setType(shopmark);
		scoreService.addScore(score);
	}

	/**
	 * 交易记录(消费记录)
	 * 
	 * @param shopmark
	 * @param dateTime
	 */
	public void addConsume(int shopmark, String dateTime) {
		User user = (User) session.get("user");
		Consume consume = new Consume();
		consume.setMemberName(findMemberName(member).getName() == null ? ""
				: findMemberName(member).getName());
		consume.setMemberMobile(member.getMobile());
		consume.setShopName(findShopName(shop).getName() == null ? ""
				: findShopName(shop).getName());
		consume.setUserName(user.getUserName());
		Account ac = new Account();
		ac.setId(this.member.getEaId());
		ac = accountService.findAccountById(ac);
		consume.setEaName(ac.getName());
		consume.setUserId(user.getId());
		consume.setEaId(this.member.getEaId());
		consume.setMemberId(this.member.getId());
		consume.setShopId(this.shop.getId());
		consume.setCreateTime(dateTime);
		consume.setMoney((Double.parseDouble(this.money)));
		consume.setType(shopmark);
		consumeService.addConsume(consume);
	}

	/**
	 * 会员充值
	 * 
	 * @return
	 * @throws ParseException
	 */
	public String balance() throws ParseException {
		Object obj = session.get("user");
		if (obj == null) {
			result = "系统异常，请重新登录";
			return "error";
		}

		if (StringUtils.isBlank(money)) {
			result = "系统异常，请重新登录";
			return "error";
		}

		if (this.member == null) {
			result = "系统异常，请重新登录";
			return "error";
		}

		if (this.shop == null) {
			result = "系统异常，请重新登录";
			return "error";
		}

		try {
			Long eaId = this.member.getEaId();
			User user = (User) obj;

			// 查询c_base_member
			if (this.baseMember == null) {
				this.baseMember = new BaseMember();
			}

			this.baseMember.setBalance(Double.parseDouble(money));
			this.baseMember.setEaId(eaId);
			this.baseMember.setMemberId(this.member.getId());

			BaseMember bm = baseMemberService
					.getOneBaseMemberByMemberIdAndEaId(this.member.getId(),
							eaId);

			if (bm == null) {
				// 添加新数据
				this.baseMember.setCreateTime(getCreateTime());
				BgiveRule rule = bGiveRuleService.getEaGiveRule(eaId);
				if (rule != null)
					this.baseMember.setScore(rule.getGiveValue());
				else
					this.baseMember.setScore(0d);
				this.baseMember.setLevel(getMemberLevelname1(eaId,
						this.baseMember.getScore()));

				baseMemberService.save(this.baseMember);
			}
			else {
				// 更新原有数据
				baseMemberService.updateBaseMemberBanlance(this.baseMember);
			}

			addBalance(user);
		}
		catch (Exception e) {
			logger.error("会员充值报错", e);
		}

		return "balance";
	}

	/**
	 * 会员充值30秒
	 * 
	 * @return
	 * @throws ParseException
	 */
	public String timeOutBalance() throws ParseException {
		long seconds = 61;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// 获得userid
		User user = (User) session.get("user");
		this.shop = new Shop();
		this.shop.setId(user.getShopId());
		this.shop = (Shop) shopService.getOneShop(shop);
		this.member = new Member();
		this.member.setEaId(this.shop.getEaId());
		this.member.setMobile(memberMobile);
		// 获得memberId
		this.member = (Member) memberService.getmemberByMobile(this.member);
		Balance balance = new Balance();
		balance.setShopId(this.shop.getId());
		balance.setMemberId(this.member.getId());
		List<Balance> blist = balanceService.getBalancesByshop(balance);
		if (blist.size() == 0) {
			timeOut = false;
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("timeOut", timeOut);
			result = super.mapTojson(map);
			return "timeOutBalance";
		}
		String balanceStr = blist.get(0).getCreateTime();
		Date exDate = df.parse(balanceStr);
		Date currentDate = new Date();
		long diff = currentDate.getTime() - exDate.getTime();
		seconds = diff / 1000;
		if (seconds <= spaceTime) {
			timeOut = true;
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("timeOut", timeOut);
			result = super.mapTojson(map);
			return "timeOutBalance";
		}
		timeOut = false;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("timeOut", timeOut);
		result = super.mapTojson(map);
		return "timeOutBalance";
	}

	/**
	 * 添加充值记录 现金方式充值
	 */
	public void addBalance(User user) {
		Balance balance = new Balance();
		String mName = findMemberName(this.member).getName();
		String shopName = findShopName(this.shop).getName();
		balance.setMemberName(mName == null ? "" : mName);
		balance.setMemberMobile(this.member.getMobile());
		balance.setShopName(shopName == null ? "" : shopName);
		balance.setUserName(user.getUserName());
		Account ac = new Account();
		ac.setId(this.member.getEaId());
		ac = accountService.findAccountById(ac);
		balance.setEaName(ac.getName());
		balance.setUserId(user.getId());
		balance.setCreateTime(getCreateTime());
		balance.setEaId(this.member.getEaId());
		balance.setMemberId(this.member.getId());
		balance.setShopId(this.shop.getId());
		balance.setMoney(Double.parseDouble(money));
		balance.setType(1); // 充值方式： 现金
		balanceService.addBalance(balance);
	}

	/**
	 * 会员兑换
	 * 
	 * @return
	 * @throws ParseException
	 */
	public String exchange() throws ParseException {
		try {
			if (this.member == null) {
				result = "系统异常，请重新登录";
				return "error";
			}

			Long eaId = this.member.getEaId();

			if (eaId == null) {
				result = "系统异常，请重新登录";
				return "error";
			}

			Long memberId = this.member.getId();

			if (memberId == null) {
				result = "系统异常，请重新登录";
				return "error";
			}

			if (StringUtils.isBlank(exScore)) {
				result = "系统异常，请重新登录";
				return "error";
			}

			// 更新商品库存
			if (StringUtils.isBlank(exGoodid)) {
				back = "3";
				return "exchange";
			}
			ExchangeGood good = new ExchangeGood();
			good.setId(Long.valueOf(exGoodid));
			good = exchangeGoodsService.getExgoodById(good);
			if (good == null) {
				back = "3";
				return "exchange";
			}
			int num = good.getAmount();
			if (num > 0) {
				good.setAmount(Integer.valueOf(num - 1));
				this.exchangeGoodsService.updateExgoodamout(good);
			}
			else {
				back = "2";
				return "exchange";
			}

			// 更新会员详情表
			// BaseAct act = new BaseAct();
			// act.setMemberId(member.getId());
			// act = baseactService.getOneBaseAct(act);
			// this.baseact.setId(act.getId());
			// this.baseact.setScore(act.getScore() -
			// Double.parseDouble(exScore));
			// this.baseact.setBalance(act.getBalance());
			// // 设置积分等级
			// // getMemberLevelname(member, baseact);
			// baseact.setLevel(member.getLevelName());
			// this.baseactService.updateBaseAct(this.baseact);

			// 更新c_base_member表
			BaseMember mber = new BaseMember();
			mber = baseMemberService.getOneBaseMemberByMemberIdAndEaId(
					memberId, eaId);

			if (mber == null) {
				back = "5";
				return "exchange";
			}

			double newScore = mber.getScore() - Double.parseDouble(exScore);
			if (newScore < 0) {
				back = "4";
				return "exchange";
			}
			mber.setScore(newScore);
			mber.setLevel(getMemberLevelname1(eaId, newScore));
			// 不需更新余额字段
			mber.setBalance(null);
			baseMemberService.updateBaseMember(mber);

			// 添加兑换记录
			addExchange();

			back = "1";
			return "exchange";
		}
		catch (Exception e) {
			logger.error("兑换商品报错", e);
		}
		return NONE;
	}

	/**
	 * 商品兑换30秒验证 会员充值30秒
	 * 
	 * @return
	 * @throws ParseException
	 */
	public String timeOutExchageLog() throws ParseException {
		long seconds = 61;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// 获得userid
		User user = (User) session.get("user");
		this.shop = new Shop();
		this.shop.setId(user.getShopId());
		this.shop = (Shop) shopService.getOneShop(shop);
		this.member = new Member();
		this.member.setEaId(this.shop.getEaId());
		this.member.setMobile(memberMobile);
		// 获得memberId
		this.member = (Member) memberService.getmemberByMobile(this.member);
		ExchangeLog exchageLog = new ExchangeLog();
		exchageLog.setShopId(this.shop.getId());
		exchageLog.setMemberId(this.member.getId());
		List<ExchangeLog> elist = exchangeLogsService
				.getExLogsByshop(exchageLog);
		if (elist.size() == 0) {
			timeOut = false;
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("timeOut", timeOut);
			result = super.mapTojson(map);
			return "timeOutExchageLog";
		}
		String exchageLogStr = elist.get(0).getCreateTime();
		Date exDate = df.parse(exchageLogStr);
		Date currentDate = new Date();
		long diff = currentDate.getTime() - exDate.getTime();
		seconds = diff / 1000;
		if (seconds <= spaceTime) {
			timeOut = true;
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("timeOut", timeOut);
			result = super.mapTojson(map);
			return "timeOutExchageLog";
		}
		timeOut = false;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("timeOut", timeOut);
		result = super.mapTojson(map);
		return "timeOutExchageLog";
	}

	/**
	 * 兑换记录
	 */
	public void addExchange() {
		this.exGood = (ExchangeGood) exchangeGoodsService.getOneExgoodbyId(Long
				.parseLong(exGoodid));
		ExchangeLog exchangelog = new ExchangeLog();
		exchangelog.setCreateTime(super.getCreateTime());
		exchangelog.setGoodId(this.exGood.getId());
		exchangelog.setEaId(this.exGood.getEaId());
		exchangelog.setShopId(this.exGood.getShopId());
		exchangelog.setMemberId(this.member.getId());
		exchangelog.setMember(this.member);
		exchangelog.setUserName(((User)session.get("user")).getUserName());
		exchangeLogsService.addAddExlogs(exchangelog);
	}

	/**
	 * 会员注册信息录入
	 * 
	 * @return
	 */
	public String addMember() {
		// 管理平台或前台添加新会员
		// 1、首先查找c_member表中有没有该手机号
		// 1.1、如果有就查询c_base_member中该手机号有没有关联该企业
		// 1.1.1、如果关联了，就提示该会员已添加
		// 1.1.2、如果没关联，就关联该会员，初始化会员数据，提示添加成功
		// 1.2、如果c_member表中没有改手机号，添加到c_member表中，再执行1.1.2步骤

		String temp = "error";
		String mobile = null;
		try {
			mobile = this.member.getMobile().trim();
		}
		catch (Exception e) {
			logger.error("手机号为空", e);
			result = "请输入手机号！";
			if (addplace.equals("account"))
				temp = "addByAccount";
			else if (addplace.equals("user"))
				temp = "addByUser";
			return temp;
		}

		this.member.setMobile(mobile);
		// 在c_member表中查询该手机号
		Member m = memberService.getmemberByMobile(this.member);

		Account account = null;
		Object obj1 = session.get("account");
		if (obj1 != null) {
			account = (Account) obj1;
		}
		User user = null;
		Object obj2 = session.get("user");
		if (obj2 != null) {
			user = (User) obj2;
		}

		// 设置this.member和bGiveRule的eaId
		bGiveRule = new BgiveRule();
		if (account != null) {
			this.member.setEaId(account.getId());
			bGiveRule.setEaId(account.getId());
		}
		if (user != null) {
			Shop shop = new Shop();
			shop.setId(user.getShopId());
			shop = shopService.getShopById(shop);
			this.member.setEaId(shop.getEaId());
			bGiveRule.setEaId(shop.getEaId());
		}

		// 判断在c_member表中是否已注册
		if (m != null) {
			// 已在c_member表中注册
			BaseMember mber = baseMemberService
					.getOneBaseMemberByMemberIdAndEaId(m.getId(),
							this.member.getEaId());
			// 判断c_base_member中该手机号有没有关联该企业
			if (mber != null) {
				// 已关联
				result = "手机号已注册！";
				if (addplace.equals("account"))
					temp = "addByAccount";
				else if (addplace.equals("user"))
					temp = "addByUser";
				return temp;
			}
			// 没关联, 添加到c_base_member表中
			addMemberInBaseMember(m.getId());
			result = "会员注册成功！";
			if (addplace.equals("account"))
				temp = "addByAccount";
			else if (addplace.equals("user"))
				temp = "addByUser";
			return temp;
		}

		// 没有在c_member表中注册
		this.member.setType(1); // 会员类型
		this.member.setCreateTime(getCreateTime());

		// 生成6位数随机密码并短信发送给用户
		SendPswSms sms = new SendPswSms();
		Map<String, Object> smsMap = sms.sendSMS(member.getMobile().trim());
		String code = (String) smsMap.get("code");
		if (!"2".equals(code)) {
			// 发送失败
			result = "添加失败！";
			if (addplace.equals("account"))
				temp = "addByAccount";
			else if (addplace.equals("user"))
				temp = "addByUser";
			return temp;
		}

		// 保存发送短信记录
		SMSLog smsLog = new SMSLog();
		smsLog.setCreateTime(getCreateTime());
		smsLog.setType(4); // 4代表了会员注册时发送手机号验证码
		smsLog.setMobile((String) smsMap.get("mobile"));
		smsLog.setContent((String) smsMap.get("content"));
		smsLog.setSend("2".equals(code) ? 1 : 2); // 1、发送成功；2、发送失败
		smsLogService.addSMSLog(smsLog);

		int pswCode = (Integer) smsMap.get("psw_code");
		this.member.setPassword(MD5Util.MD5(Integer.toString(pswCode)));

		// 在c_member表中添加该会员
		memberService.addMember(this.member);
		// 在c_base_member表中关联该会员
		addMemberInBaseMember(this.member.getId());

		result = "添加成功！";
		if (addplace.equals("account"))
			temp = "addByAccount";
		else if (addplace.equals("user"))
			temp = "addByUser";

		return temp;
	}

	private void addMemberInBaseMember(Long memberId) {
		this.baseMember = new BaseMember();
		this.baseMember.setCreateTime(getCreateTime());
		this.baseMember.setEaId(this.member.getEaId());
		// 查询注册时奖励积分
		BgiveRule rule = new BgiveRule();
		rule.setEaId(this.member.getEaId());
		rule.setType(1);
		rule = bGiveRuleService.findBgiveRuleByType(rule);
		if (rule != null) {
			this.baseMember.setScore(rule.getGiveValue());
		}
		else {
			this.baseMember.setScore(0d);
		}
		this.baseMember.setBalance(0d);
		this.baseMember.setLevel(getMemberLevelname1(this.baseMember.getEaId(),
				this.baseMember.getScore()));
		this.baseMember.setMemberId(memberId);
		baseMemberService.save(this.baseMember);
	}

	/**
	 * 验证手机号是否已被注册
	 * 
	 * @return
	 */
	public String verifyMobile() {
		Account account = (Account) session.get("account");
		User user = (User) session.get("user");
		Member member = new Member();
		if (account != null) {
			member.setEaId(account.getId());
		}
		if (user != null) {
			Shop shop = new Shop();
			shop.setId(user.getShopId());
			shop = shopService.getShopById(shop);
			member.setEaId(shop.getEaId());
		}
		member.setMobile(mobile);
		if (memberService.checkActMobile(member)) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("temp", "手机号已被注册");
			json = super.mapTojson(map);
		}
		return "verifyReturn";
	}

	/**
	 * 跳转到会员导入页面
	 */
	public String toReadCSVFile() {
		return "toReadCSVFile";
	}

	/**
	 * 跳转到添加会员页面
	 */
	public String toaAddMember() {
		return "toaAddMember";
	}

	/**
	 * 计算积分会员等级
	 * 
	 * @param member
	 * @param baseMember
	 */
	private void getMemberLevelname(Member member, BaseMember baseMember) {
		EnterpriseIntegralRule integralRule = new EnterpriseIntegralRule();
		integralRule.setEaId(member.getEaId());
		List<EnterpriseIntegralRule> integralRules = enterpriseIntegralRuleService
				.watchEnterpriseIntegralRule(integralRule);
		double scoreSum = baseMember.getScore();
		for (int i = 0; i < integralRules.size(); i++) {
			if ((int) scoreSum >= integralRules.get(i).getMinValue()
					&& scoreSum < integralRules.get(i).getMaxValue()) {
				member.setLevelName(integralRules.get(i).getName());
				break;
			}
			if (i == integralRules.size() - 1) {
				if (scoreSum >= integralRules.get(i).getMaxValue()) {
					member.setLevelName(integralRules.get(i).getName());
				}
			}
		}
	}

	/**
	 * 获取积分会员等级
	 */
	private String getMemberLevelname1(Long eaId, Double score) {
		String levelName = "";
		EnterpriseIntegralRule integralRule = new EnterpriseIntegralRule();
		integralRule.setEaId(eaId);
		List<EnterpriseIntegralRule> integralRules = enterpriseIntegralRuleService
				.watchEnterpriseIntegralRule(integralRule);
		for (int i = 0; i < integralRules.size(); i++) {
			if (score.intValue() >= integralRules.get(i).getMinValue()
					&& score < integralRules.get(i).getMaxValue()) {
				levelName = integralRules.get(i).getName();
				break;
			}
			if (i == integralRules.size() - 1) {
				if (score >= integralRules.get(i).getMaxValue()) {
					member.setLevelName(integralRules.get(i).getName());
					levelName = integralRules.get(i).getName();
				}
			}
		}
		return levelName;
	}

	/**
	 * 根据积分规则修改积分
	 */
	private void countBaseMemberSorce(Long eaId) {
		String sMoney = this.money.substring(0,
				this.money.indexOf(".") != -1 ? this.money.indexOf(".")
						: this.money.length());
		Double score = this.baseMember.getScore();
		BgiveRule rule = bGiveRuleService.getGiveRuleByTime(getCreateTime(),
				eaId);
		if (rule == null) {
			this.baseMember.setScore(score
					+ (scoreOfConsume = Double.parseDouble(sMoney)));
		}
		else {
			int type = rule.getType();
			if (type == 2) {
				this.baseMember.setScore(score
						+ (scoreOfConsume = Double.parseDouble(sMoney)
								* rule.getRaiseValue()));
			}
			else if (type == 3) {
				this.baseMember.setScore(score
						+ (scoreOfConsume = Double.parseDouble(sMoney)
								+ rule.getRaiseValue()));
			}
			else {
				this.baseMember.setScore(score
						+ (scoreOfConsume = Double.parseDouble(sMoney)));
			}
		}
	}

	/**
	 * 根据id查询会员
	 */
	private Member findMemberName(Member member) {
		return memberService.getMemberById(member);
	}

	/**
	 * 根据id查询店铺
	 */
	private Shop findShopName(Shop shop) {
		return shopService.getShopById(shop);
	}

	/**
	 * 返回累计消费会员数量
	 */
	public Integer findCmeMb(Long eaId) {
		List<Long> memberIdsInBalance = balanceService
				.findMemberIdFromBalance(eaId);
		List<Long> memberIdsInScore = consumeService
				.findMemberIdFromConsume(eaId);
		List<Long> memberIdsInExchangeLog = exchangeLogsService
				.findMemberIdFromExchangeLog(eaId);

		List<Long> memberids = new ArrayList<Long>();

		for (Long mId : memberIdsInBalance) {
			memberids.add(mId);
		}
		for (Long mId : memberIdsInScore) {
			if (memberids.contains(mId)) {
				continue;
			}
			memberids.add(mId);
		}
		for (Long mId : memberIdsInExchangeLog) {
			if (memberids.contains(mId)) {
				continue;
			}
			memberids.add(mId);
		}

		List<Member> tempMembers = new ArrayList<Member>();

		for (Long mId : memberids) {
			Member member = new Member();
			member.setId(mId);
			member = memberService.getMemberById(member);
			if (member != null) {
				tempMembers.add(member);
			}
		}

		return tempMembers.size();
	}

	/**
	 * 检查昵称
	 */
	public String checkNickName() {
		member = new Member();
		member.setNickName(nickName);
		boolean isCheck = memberService.checkNickName(member);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("isCheck", isCheck);
		result = super.mapTojson(map);
		return "checkNickName";
	}

	/**
	 * 检查手机号
	 */
	public String checkMobile() {
		member = new Member();
		member.setMobile(mobile);
		boolean isCheck = memberService.checkMobile(member);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("isCheck", isCheck);
		result = super.mapTojson(map);
		return "checkMobile";
	}

	/**
	 * 会员使用余额消费时先发送验证码到会员手机
	 */
	public String sendSmsForConsumeByBalance() {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isBlank(memberMobile)) {
			map.put("message", "手机号不存在，请重新输入！");
			result = super.mapTojson(map);
			return "sendSmsForConsumeByBalance";
		}

		Object[] obj = REG_CODE_MAP.get("wm-shopping-" + memberMobile);
		long time = System.currentTimeMillis() / 1000;
		if (obj != null) {
			// 60秒内不重复发送
			long seconds = time - ((Long) obj[0]).longValue();
			if (seconds <= this.spaceTimeForSms) {
				map.put("message", "发送验证码太频繁，请稍后再试");
				result = super.mapTojson(map);
				return "sendSmsForConsumeByBalance";
			}
		}

		SendSms sms = new SendSms();
		Map<String, Object> smsMap = sms.sendSMS(memberMobile);
		String code = (String) smsMap.get("code");
		if (!"2".equals(code)) {
			map.put("message", "验证码发送失败，请稍后重新发送！");
			result = super.mapTojson(map);
			return "sendSmsForConsumeByBalance";
		}

		// 取得验证码
		int mobileCode = (Integer) smsMap.get("mobile_code");

		REG_CODE_MAP.put("wm-shopping-" + memberMobile,
				new Object[] { System.currentTimeMillis() / 1000, mobileCode });

		// 保存发送短信记录
		SMSLog smsLog = new SMSLog();
		smsLog.setCreateTime(getCreateTime());
		smsLog.setType(10); // 10代表余额支付时向会员手机发送验证码
		smsLog.setMobile((String) smsMap.get("mobile"));
		smsLog.setContent((String) smsMap.get("content"));
		smsLog.setSend("2".equals(code) ? 1 : 2); // 1、发送成功；2、发送失败
		smsLogService.addSMSLog(smsLog);

		map.put("message", "ok");
		result = super.mapTojson(map);

		return "sendSmsForConsumeByBalance";
	}

	/**
	 * 验证余额支付的会员收到的验证码
	 */
	public String verifyForConsumeByBalance() {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isBlank(memberMobile)) {
			map.put("message", "手机号不存在，请重新输入！");
			result = super.mapTojson(map);
			return "verifyForConsumeByBalance";
		}

		if (StringUtils.isBlank(verifyCodeForConsume)) {
			map.put("message", "请输入验证码！");
			result = super.mapTojson(map);
			return "verifyForConsumeByBalance";
		}

		Object[] object = REG_CODE_MAP.get("wm-shopping-" + memberMobile);
		if (object == null) {
			map.put("message", "您可能未发送验证码或验证码已过期！");
			result = super.mapTojson(map);
			return "verifyForConsumeByBalance";
		}

		// 判断验证码
		if (!object[1].toString().equals(verifyCodeForConsume)) {
			map.put("message", "验证码不正确！");
			result = super.mapTojson(map);
			return "verifyForConsumeByBalance";
		}

		map.put("message", "ok");
		result = super.mapTojson(map);

		return "verifyForConsumeByBalance";
	}

	public MemberService getMemberService() {
		return memberService;
	}

	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public List<Member> getMembers() {
		return members;
	}

	public void setMembers(List<Member> members) {
		this.members = members;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public ShopService getShopService() {
		return shopService;
	}

	public void setShopService(ShopService shopService) {
		this.shopService = shopService;
	}

	public BaseAct getBaseact() {
		return baseact;
	}

	public void setBaseact(BaseAct baseact) {
		this.baseact = baseact;
	}

	public BaseActService getBaseactService() {
		return baseactService;
	}

	public void setBaseactService(BaseActService baseactService) {
		this.baseactService = baseactService;
	}

	public String getMoney() {
		return money;
	}

	public void setMoney(String money) {
		this.money = money;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	public ScoreService getScoreService() {
		return scoreService;
	}

	public void setScoreService(ScoreService scoreService) {
		this.scoreService = scoreService;
	}

	public String getBalance() {
		return balance;
	}

	public void setBalance(String balance) {
		this.balance = balance;
	}

	public String getScore() {
		return score;
	}

	public void setScore(String score) {
		this.score = score;
	}

	public String getSeekType() {
		return seekType;
	}

	public void setSeekType(String seekType) {
		this.seekType = seekType;
	}

	public ConsumeService getConsumeService() {
		return consumeService;
	}

	public void setConsumeService(ConsumeService consumeService) {
		this.consumeService = consumeService;
	}

	public BalanceService getBalanceService() {
		return balanceService;
	}

	public void setBalanceService(BalanceService balanceService) {
		this.balanceService = balanceService;
	}

	public int getLine() {
		return line;
	}

	public void setLine(int line) {
		this.line = line;
	}

	public EnterpriseIntegralRuleService getEnterpriseIntegralRuleService() {
		return enterpriseIntegralRuleService;
	}

	public void setEnterpriseIntegralRuleService(
			EnterpriseIntegralRuleService enterpriseIntegralRuleService) {
		this.enterpriseIntegralRuleService = enterpriseIntegralRuleService;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public ExchangeGoodsService getExchangeGoodsService() {
		return exchangeGoodsService;
	}

	public void setExchangeGoodsService(
			ExchangeGoodsService exchangeGoodsService) {
		this.exchangeGoodsService = exchangeGoodsService;
	}

	public ExchangeLogsService getExchangeLogsService() {
		return exchangeLogsService;
	}

	public void setExchangeLogsService(ExchangeLogsService exchangeLogsService) {
		this.exchangeLogsService = exchangeLogsService;
	}

	public String getExGoodid() {
		return exGoodid;
	}

	public void setExGoodid(String exGoodid) {
		this.exGoodid = exGoodid;
	}

	public ExchangeGood getExGood() {
		return exGood;
	}

	public void setExGood(ExchangeGood exGood) {
		this.exGood = exGood;
	}

	public List<ExchangeGood> getExGoods() {
		return exGoods;
	}

	public void setExGoods(List<ExchangeGood> exGoods) {
		this.exGoods = exGoods;
	}

	public ExchangeLog getExchangeLog() {
		return exchangeLog;
	}

	public void setExchangeLog(ExchangeLog exchangeLog) {
		this.exchangeLog = exchangeLog;
	}

	public List<ExchangeLog> getExchangeLogs() {
		return exchangeLogs;
	}

	public void setExchangeLogs(List<ExchangeLog> exchangeLogs) {
		this.exchangeLogs = exchangeLogs;
	}

	public String getExScore() {
		return exScore;
	}

	public void setExScore(String exScore) {
		this.exScore = exScore;
	}

	public List<Consume> getConsumes() {
		return consumes;
	}

	public void setConsumes(List<Consume> consumes) {
		this.consumes = consumes;
	}

	public List<Balance> getBalances() {
		return balances;
	}

	public void setBalances(List<Balance> balances) {
		this.balances = balances;
	}

	public String getJson() {
		return json;
	}

	public void setJson(String json) {
		this.json = json;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getAddplace() {
		return addplace;
	}

	public void setAddplace(String addplace) {
		this.addplace = addplace;
	}

	public String getBack() {
		return back;
	}

	public void setBack(String back) {
		this.back = back;
	}

	public AccountService getAccountService() {
		return accountService;
	}

	public void setAccountService(AccountService accountService) {
		this.accountService = accountService;
	}

	public BgiveRuleService getbGiveRuleService() {
		return bGiveRuleService;
	}

	public void setbGiveRuleService(BgiveRuleService bGiveRuleService) {
		this.bGiveRuleService = bGiveRuleService;
	}

	public List<BgiveRule> getbGiveRules() {
		return bGiveRules;
	}

	public void setbGiveRules(List<BgiveRule> bGiveRules) {
		this.bGiveRules = bGiveRules;
	}

	public BgiveRule getbGiveRule() {
		return bGiveRule;
	}

	public void setbGiveRule(BgiveRule bGiveRule) {
		this.bGiveRule = bGiveRule;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public long getSpaceTime() {
		return spaceTime;
	}

	public String getMemberMobile() {
		return memberMobile;
	}

	public void setMemberMobile(String memberMobile) {
		this.memberMobile = memberMobile;
	}

	public Boolean getTimeOut() {
		return timeOut;
	}

	public void setTimeOut(Boolean timeOut) {
		this.timeOut = timeOut;
	}

	public String getSearchOneMember() {
		return searchOneMember;
	}

	public void setSearchOneMember(String searchOneMember) {
		this.searchOneMember = searchOneMember;
	}

	public Integer getMemberCount() {
		return memberCount;
	}

	public void setMemberCount(Integer memberCount) {
		this.memberCount = memberCount;
	}

	public String getQyAuthority() {
		return qyAuthority;
	}

	public void setQyAuthority(String qyAuthority) {
		this.qyAuthority = qyAuthority;
	}

	public BApplicationService getbApplicationService() {
		return bApplicationService;
	}

	public void setbApplicationService(BApplicationService bApplicationService) {
		this.bApplicationService = bApplicationService;
	}

	public String getMessageMoney() {
		return messageMoney;
	}

	public void setMessageMoney(String messageMoney) {
		this.messageMoney = messageMoney;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public SMSLogService getSmsLogService() {
		return smsLogService;
	}

	public void setSmsLogService(SMSLogService smsLogService) {
		this.smsLogService = smsLogService;
	}

	public double getMemberLogScore() {
		return memberLogScore;
	}

	public void setMemberLogScore(double memberLogScore) {
		this.memberLogScore = memberLogScore;
	}

	public double getMemberLogBalance() {
		return memberLogBalance;
	}

	public void setMemberLogBalance(double memberLogBalance) {
		this.memberLogBalance = memberLogBalance;
	}

	public BaseMemberService getBaseMemberService() {
		return baseMemberService;
	}

	public void setBaseMemberService(BaseMemberService baseMemberService) {
		this.baseMemberService = baseMemberService;
	}

	public BaseMember getBaseMember() {
		return baseMember;
	}

	public List<BaseMember> getBaseMembers() {
		return baseMembers;
	}

	public void setBaseMembers(List<BaseMember> baseMembers) {
		this.baseMembers = baseMembers;
	}

	public void setBaseMember(BaseMember baseMember) {
		this.baseMember = baseMember;
	}

	public Double getScoreOfConsume() {
		return scoreOfConsume;
	}

	public void setScoreOfConsume(Double scoreOfConsume) {
		this.scoreOfConsume = scoreOfConsume;
	}

	public String getVerifyCodeForConsume() {
		return verifyCodeForConsume;
	}

	public void setVerifyCodeForConsume(String verifyCodeForConsume) {
		this.verifyCodeForConsume = verifyCodeForConsume;
	}

	public Consume getConsume() {
		return consume;
	}

	public void setConsume(Consume consume) {
		this.consume = consume;
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
}
